<template>
  <div class="user-container">
    <header>user_center</header>
    <!-- <a href="xmind:">打开xmind</a> -->
    <section>
      <div class="task-list">
        <GridLayout
          :layout.sync="VueGridLayouts"
          :col-num="12"
          :row-height="120"
          :is-draggable="true"
          :is-resizable="true"
          :is-mirrored="false"
          :vertical-compact="true"
          :margin="[20, 20]"
          :use-css-transforms="true"
        >
          <grid-item
            v-for="grid in VueGridLayouts"
            :key="grid.i"
            :x="grid.x"
            :y="grid.y"
            :w="grid.w"
            :minW="grid.minW"
            :h="grid.h"
            :i="grid.i"
            drag-allow-from=".vue-draggable-handle"
            drag-ignore-from=".no-drag"
          >
            <div class="vue-draggable-handle">
              <i class="iconfont icon-drag" />
              <span>{{ grid.title }}</span>
            </div>
            <Component class="no-drag" :is="grid.i" />
          </grid-item>
        </GridLayout>
      </div>
      <!-- <div class="user-list">
        <div class="header row">
          <div class="icon">
            <span>{{ username[0] }}</span>
            <div class="message">
              <h4>{{ username }}</h4>
              <div class="key-words">
                <h6>{{ position }}</h6>
              </div>
            </div>
          </div>
          <div class="tools">
            <el-tooltip
              class="tool"
              :effect="theme === 'dark' ? 'light' : 'dark'"
              content="切换"
              placement="top"
            >
              <i class="iconfont icon-exchange"></i>
            </el-tooltip>
            <el-tooltip
              class="tool"
              :effect="theme === 'dark' ? 'light' : 'dark'"
              content="详情"
              placement="top"
            >
              <i class="iconfont icon-details"></i>
            </el-tooltip>
          </div>
        </div>
        <div class="statistic row">
          <div class="statistic-item">
            <h4>已完成任务数:</h4>
            <span>{{ 23 }}</span>
            <i class="iconfont icon-arrow-right"></i>
          </div>
          <div class="statistic-item">
            <h4>待完成任务数:</h4>
            <span>{{ 15 }}</span>
            <i class="iconfont icon-arrow-right"></i>
          </div>
          <div class="statistic-item">
            <h4>超时任务数:</h4>
            <span>{{ 7 }}</span>
            <i class="iconfont icon-arrow-right"></i>
          </div>
          <div class="statistic-item">
            <h4>打回任务数:</h4>
            <span>{{ 5 }}</span>
            <i class="iconfont icon-arrow-right"></i>
          </div>
        </div>
        <div class="echarts row">
          <basic-line />
        </div>
      </div> -->
    </section>
  </div>
</template>

<script lang="ts">
import Vue from 'vue'
import { Component } from 'vue-property-decorator'
import { Getter } from 'vuex-class'
import { GridItem, GridLayout, GridItemProps } from 'vue-grid-layout'
import WSMembers from './components/User/ws-members.vue'
import WSTasks from './components/User/ws-tasks.vue'
import WSRanks from './components/User/ws-ranks.vue'
interface GridItemExtendOptions extends GridItemProps {
  title: string
}
@Component({
  components: {
    GridLayout,
    GridItem,
    WSMembers,
    WSTasks,
    WSRanks
  }
})
class User extends Vue {
  @Getter('name') username!: string
  @Getter('department') department!: string
  @Getter('position') position!: string
  @Getter('theme') theme!: 'dark' | 'light'
  VueGridLayouts: GridItemExtendOptions[] = [
    { x: 0, y: 0, w: 3, h: 3, minW: 3, i: 'WSMembers', title: '员工管理' },
    { x: 3, y: 0, w: 7, h: 5, minW: 7, i: 'WSTasks', title: '任务列表' },
    { x: 0, y: 3, w: 3, h: 2, minW: 3, i: 'WSRanks', title: '业务排行榜' }
  ]
}
export default User
</script>

<style lang="less" scoped>
@import '~@/styles/theme.less';
@import '~@/styles/layout.less';
h4 {
  margin: 0;
  font-size: 14px;
  font-weight: 400;
}
h6 {
  margin: 0;
  font-size: 12px;
  font-weight: 400;
}
.user-container {
  box-sizing: border-box;
  padding: 10px 20px;
  width: 100%;
  height: calc(100vh - 50px);
  #flex(column, center, flex-start);
  #color(background-color, --primary-bg-color);
  header {
    box-sizing: border-box;
    padding: 10px;
    margin-bottom: 10px;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    #color(color, --primary-text-color);
    #color(background-color, --module-bg-color);
  }
  section {
    width: 100%;
    flex: 1;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    overflow: auto;
    #color(background-color, --module-bg-color);
    .task-list {
      flex: 1;
      height: 100%;
      overflow: auto;
      display: flex;
      align-items: flex-start;
      justify-content: space-between;
      /deep/.vue-grid-layout {
        width: 100%;
        height: 100%;
        .vue-grid-item {
          position: relative;
          box-sizing: border-box;
          padding: 10px;
          border: solid 1px;
          touch-action: none;
          #color(border-color, --primary-border-color);
          #color(background-color, --module-bg-color);
          #shadow-color(0, 6px, 12px, 1px, --lighter-shadow-color);
          .vue-draggable-handle {
            position: absolute;
            top: 10px;
            left: 10px;
            z-index: 2;
            #flex(row, center, flex-start);
            i {
              font-size: 20px;
              transform: rotate(90deg);
            }
            span {
              font-weight: 900;
              #color(color, --primary-text-color);
            }
          }
          .no-drag {
            height: 100%;
            overflow: auto;
          }
        }
        .vue-grid-placeholder {
          #color(background, --primary-blue-color) !important;
        }
      }
      .column {
        box-sizing: border-box;
        padding: 0 20px;
        height: 100%;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: flex-start;
        .column-header {
          width: 100%;
          margin-bottom: 10px;
          display: flex;
          align-items: center;
          justify-content: space-between;
          span {
            box-sizing: border-box;
            padding: 4px 8px;
            display: flex;
            align-items: center;
            border-radius: 2px;
            font-size: 12px;
            color: #ffffff;
            transition: all 0.2s ease;
            box-shadow: 0 0 0 rgba(0, 0, 0, 0.8);
            cursor: pointer;
            #color(background-color, --primary-blue-color);
          }
          span:last-child:hover {
            box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.8);
            [data-theme='dark'] & {
              box-shadow: 4px 4px 0 rgba(255, 255, 255, 0.8);
            }
            #color(background-color, --heavier-blue-color);
          }
        }
        .column-body {
          flex: 1;
        }
      }
    }
    .user-list {
      box-sizing: border-box;
      padding: 10px;
      width: 300px;
      height: 100%;
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: flex-start;
      #color(color, --primary-text-color);
      #color(background-color, --module-bg-color);
      .row {
        width: 100%;
        display: flex;
        align-items: center;
        justify-content: space-between;
      }
      .header {
        margin-bottom: 20px;
        font-size: 14px;
        #color(color, --primary-text-color);
        .icon {
          display: flex;
          align-items: center;
          span {
            box-sizing: border-box;
            width: 36px;
            height: 36px;
            margin-right: 10px;
            text-align: center;
            line-height: 36px;
            border-radius: 50%;
            font-size: 14px;
            color: #ffffff;
            cursor: pointer;
            #color(background-color, --primary-blue-color);
            #shadow-color(1px, 1px, 4px, 0, --primary-shadow-color);
          }
          h4 {
            margin-bottom: 2px;
          }
          .message {
            display: flex;
            flex-direction: column;
            align-items: flex-start;
            justify-content: center;
            h6 {
              box-sizing: border-box;
              margin-right: 5px;
              padding: 2px 5px;
              border-radius: 5px;
              color: #ffffff;
              #color(background-color, --lighter-blue-color);
            }
            .key-words {
              display: flex;
              align-items: center;
              white-space: nowrap;
              overflow: auto;
            }
          }
        }
        .tools {
          display: flex;
          align-items: center;
          justify-content: space-between;
          /deep/.tool {
            box-sizing: border-box;
            position: relative;
            display: flex;
            align-items: center;
            flex-direction: column;
            padding: 4px;
            border-radius: 3px;
            font-size: 20px;
            transition: all 0.2s ease;
            cursor: pointer;
            #color(color, --primary-text-color);
            .el-select {
              position: absolute;
              left: 0;
              top: 0;
              width: 30px !important;
              .el-select__tags {
                display: none;
              }
              .el-input {
                visibility: hidden;
              }
            }
          }
          .tool:hover {
            #bg-color(--primary-hover-text-color);
          }
        }
      }
      .statistic {
        flex-direction: column;
        justify-content: flex-start;
        .statistic-item {
          box-sizing: border-box;
          display: flex;
          align-items: center;
          justify-content: space-between;
          width: 100%;
          padding: 10px;
          margin-bottom: 20px;
          border: solid 1px;
          transition: all 0.3s ease;
          cursor: pointer;
          #color(border-color, --primary-border-color);
          #shadow-color(0, 0, 4px, 0, --primary-shadow-color);
          h4 {
            display: block;
            width: 36%;
            text-align: left;
          }
        }
        .statistic-item:hover {
          transform: translateY(-10px);
          #color(color, --primary-blue-color);
        }
      }
      .echarts {
        box-sizing: border-box;
        padding: 5px;
        min-height: 200px;
        border: solid 1px;
        transition: all 0.3s ease;
        #color(border-color, --primary-border-color);
        #shadow-color(0, 0, 4px, 0, --primary-shadow-color);
      }
    }
  }
}
</style>
